package com.klhappy.houyuan.utils;

import android.util.Log;

public final class LogHelper{
    private static final boolean ENABLE_LOG = true;
    private static final boolean DEBUG      = true && ENABLE_LOG;
    private static final boolean VERBOSE    = true && ENABLE_LOG;
    private static final boolean WARNING    = true && ENABLE_LOG;
    private static final boolean INFO       = true && ENABLE_LOG;
    private static final boolean ERROR      = true && ENABLE_LOG;

    private static final String  TAG        = "HouYuan";

    /**
     * @Title: getMethodInfo
     * @Description:获取调用方法的相关信息串�?
     * @return String 具体格式�?"文件�?.java[行号](方法�?): "
     */
    private final static String getMethodInfo(){
        String result = "";
        try{
            StackTraceElement ste = new Throwable().getStackTrace()[2];
            result = ste.getFileName() + "[" + ste.getLineNumber() + "]" + "(" + ste.getMethodName() + ")" + ": ";
        }
        catch(Exception e){
            result = "";
        }
        return result;
    }

    public static void i(String msg){
        if (!ENABLE_LOG){
            return;
        }
        
        if(INFO && msg != null){
            Log.i(TAG, getMethodInfo() + msg);
        }
    }

    public static void d(String msg){
        if (!ENABLE_LOG){
            return;
        }
        
        if(DEBUG && msg != null){
            Log.d(TAG, getMethodInfo() + msg);
        }
    }

    public static void v(String msg){
        if (!ENABLE_LOG){
            return;
        }
        
        if(VERBOSE && msg != null){
            Log.v(TAG, getMethodInfo() + msg);
        }
    }

    public static void w(String msg){
        if (!ENABLE_LOG){
            return;
        }
        
        if(WARNING && msg != null){
            Log.w(TAG, getMethodInfo() + msg);
        }
    }

    public static void e(String msg){
        if (!ENABLE_LOG){
            return;
        }
        
        if(ERROR && msg != null){
            Log.e(TAG, getMethodInfo() + msg);
        }
    }

}
